import { createRouter, createWebHashHistory, RouteRecordRaw } from 'vue-router'
// import HomeView from '../views/HomeView.vue'
import LoginView from '@/views/LoginView/LoginView.vue'
import LayOut from '@/views/LayOut/LayOut.vue'

const routes: Array<RouteRecordRaw> = [
  {
    path: '/',
    redirect: '/login'
  },
  {
    path: '/login',
    name: 'login',
    component: LoginView
  },
  {
    path: '/admin',
    component: LayOut,
    redirect: '/admin/welcome',
    // 可以设置/也可以不设置
    children: [
      {
        // path: '/admin/welcome',
        // 推荐
        path: 'welcome',
        // 路由懒加载
        component: () =>
          import('@/views/LayOut/WelcomeView.vue')
      }, {
        path: 'userlist',
        component: () =>
          import('@/views/UserView/UserList.vue')
      }, {
        path: 'useradd',
        component: () =>
          import('@/views/UserView/UserAdd.vue')
      }, {
        path: 'productcate',
        component: () =>
          import('@/views/ProductView/ProductCate.vue')
      }, {
        path: 'productcateadd',
        component: () =>
          import('@/views/ProductView/ProductCateAdd.vue')
      }
    ]
  }
]

const router = createRouter({
  history: createWebHashHistory(),
  routes
})

export default router
